package com.ctrl.riveradministrator.mvp.view.fragment;


import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.os.Message;
import android.view.View;
import android.widget.TextView;

import com.ctrl.riveradministrator.R;
import com.ctrl.riveradministrator.base.BaseFragment;
import com.ctrl.riveradministrator.base.BasePresenter;
import com.ctrl.riveradministrator.RaApplication;
import com.ctrl.riveradministrator.common.Constants;
import com.ctrl.riveradministrator.mvp.view.activity.login.LoginActivity;

/**
 * A simple {@link Fragment} subclass.
 */
public class UserFragment extends BaseFragment {

    public static UserFragment INSTANCE;

    private TextView username, phone, role, depart, river, service, exit, userScore;

    public static UserFragment newInstance() {
        if (INSTANCE == null) {
            INSTANCE = new UserFragment();
        }
        return INSTANCE;
    }

    public UserFragment() {
        // Required empty public constructor
    }

    @Override
    protected int bindLayout() {
        return R.layout.fragment_user;
    }

    @Override
    protected void initView(View view) {
        username = (TextView) $(view, R.id.username);
        phone = (TextView) $(view, R.id.phone);
        role = (TextView) $(view, R.id.role);
        depart = (TextView) $(view, R.id.depart);
        river = (TextView) $(view, R.id.river);
        service = (TextView) $(view, R.id.service);
        exit = (TextView) $(view, R.id.exit);
        userScore = (TextView) $(view, R.id.userScore);
        username.setText(RaApplication.sp.getString(Constants.USER_NAME, "用户昵称"));
        phone.setText(RaApplication.sp.getString(Constants.USER_PHONE, "手机号码"));
        role.setText(RaApplication.sp.getString(Constants.USER_ROLE, "用户角色"));
        depart.setText(RaApplication.sp.getString(Constants.USER_DEPARTMENT, "管理所"));
        river.setText(RaApplication.sp.getString(Constants.USER_RIVER, "河段名称"));
        service.setText(RaApplication.sp.getString(Constants.USER_SERVER, "行政服务"));
        userScore.setText("积分：150");
        exit.setOnClickListener(v -> {
            RaApplication.editor.clear().commit();
            startActivity(new Intent(getContext(), LoginActivity.class));
        });
    }

    @Override
    protected void doBusiness(Context mContext, Activity activity) {

    }

    @Override
    protected void widgetClick(View view) {

    }

    @Override
    protected void setListener() {

    }

    @Override
    public void handleMessage(Message message, int what) {

    }

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

}
